package com.powernode.common;

import lombok.Getter;

import java.util.List;

/**
 * @Description TODO
 * @Date 2022/3/27 23:50
 * @Version 1.0
 */
@Getter
public class ResultJson<T> {
    private Integer code;
    private T content;
    private String message;

    private ResultJson(ResultCode resultCode, T content, String message) {
        this.code = resultCode.getCode();
        this.content = content;
        this.message = message;
    }

    public static <T> ResultJson<T> getInstance(ResultCode resultCode, T content, String message){
        return new ResultJson(resultCode,content,message);
    }

    public static <T> ResultJson<T> success(T content, String message){
        return getInstance(ResultCode.SUCCESS,content,message);
    }

    public static <T> ResultJson<T> success(T content){
        return success(content,"");
    }

    public static <T> ResultJson<T> failed(T content, String message){
        return getInstance(ResultCode.FAILED,content,message);
    }

    public static <T> ResultJson<T> failed(String message){
        return failed(null, message);
    }
}
